import * as React from 'react'
import Button from 'antd/es/button'

interface IProps {
	title: string;
	age: number;
	onMyClick: any
}

//通过接口声明状态
interface IState {
	count: number
}

export default class Hello extends React.Component<IProps, IState> {

	constructor(props: IProps) {
		super(props)
		this.state = {
			count: 1000
		}
	}

	clickHandler = () => {
		this.setState({
			count: 2000
		})
	}

	clickMsgHandler = () => {
		console.log('clickMsgHandler')
		this.props.onMyClick('child msg')
	}

	render() {
		const { title } = this.props
		return (
			<div>
				<div>
					Hello {title}
				</div>
				<div>
					{this.state.count}
					<Button type="primary" onClick={this.clickHandler}>click</Button>
					<Button onClick={this.clickMsgHandler}>send msg</Button>
				</div>
			</div>
		)
	}
}